package com.example.myapplication3

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat


class ThirdActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_third)
        val extraData = intent.getStringExtra("extra_data")
        Log.d("ThirdActivity","extra_data is $extraData")
        val button1: Button = findViewById(R.id.button1)
        button1.setOnClickListener {
            val intent = Intent()
            intent.putExtra("data_return","Hello MainActivity!")
            setResult(RESULT_OK,intent)
            finish()
        }
    }

    @Deprecated("Deprecated in Java")
    @SuppressLint("GestureBackNavigation")
    override fun onBackPressed() {
        super.onBackPressed()
        val intent = Intent()
        intent.putExtra("data_return","Hello MainActivity!")
        setResult(RESULT_OK,intent)
        finish()
    }
}